﻿using System.Data.Entity;

namespace DemoEF.Model
{
    /// <summary>
    /// Create DbContext for Database
    /// </summary>
    public class ProductDbContext : DbContext
    {
        // to represent a table in Database ( one part of table or full table )
        public DbSet<Category> Categories { get; set; }
        public DbSet<Product> Products { get; set; }
        public DbSet<User> Users { get; set; } 

        //Demo CodeFirst Fluent API
        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Entity<Product>().Property(s => s.Name).HasMaxLength(48);
            modelBuilder.Entity<Product>().Property(s => s.Name).HasColumnName("Name_Editted");
        }

    }


}
